t = int(input().strip())
results = []
for _ in range(t):
    n = int(input().strip())
    total_abs = 0
    for _ in range(n):
        a, b, c, d = map(int, input().split())
        total_abs += abs(a - c) + abs(b - d)
    # Each move operation affects two piles, so divide by 2
    results.append(total_abs // 2)

for res in results:
    print(res)